<?php

class Resource extends Zend_Db_Table_Abstract {
	
	protected $_name = 'resource';
	protected $_id = 'id';
	
	protected $_dependentTables = array(
		'ThemeResourceMap'
	);
	
	/**
	 * Find all available resources for certain user.
	 * 
	 * @param User $user
	 * @return return resource of given user id
	 */
	function findAllAvaiableResourcesByUser($user) {
		$resources = array();
		$select = $this->select();
		$select = $select->from($this->_name, array('id', 'filename'))
		->where('user_id=?', $user)
		->orWhere('status=?', 0);
		$rows = $this->fetchAll($select);
		foreach ($rows as $row) {
			$resources[$row->id] = $row->filename;
		}
		return $resources;
	}
}
?>